package com.itheima.service.impl;

import com.itheima.domain.Book;
import com.itheima.mapper.BookMapper;
import com.itheima.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookMapper bookMapper;

    @Override
    public boolean save(Book book) {
        int i = bookMapper.save(book);
        boolean result = i > 0 ? true : false;
        return result;
    }

    @Override
    public boolean update(Book book) {
        int i = bookMapper.update(book);
        boolean result = i > 0 ? true : false;
        return result;
    }

    @Override
    public boolean deleteById(Integer id) {
        int i = bookMapper.deleteById(id);
        boolean result = i > 0 ? true : false;
        return result;
    }

    @Override
    public Book getById(Integer id) {
        Book book = bookMapper.getById(id);
        return book;
    }

    @Override
    public List<Book> getAll() {
        List<Book> bookList = bookMapper.getAll();
        return bookList;
    }
}
